home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-03
/
qbpacket.zip
/
ARITHMET.BAS
< prev
next >
Wrap
BASIC Source File
|
1992-03-21
|
2KB
|
96 lines
DECLARE SUB Add (NoNum)
DECLARE SUB Subtract ()
DECLARE SUB Multiply ()
DECLARE SUB Divide ()
DIM SHARED Num(100)
DO
CLS
COLOR 6
LOCATE 1, 38
PRINT "MENU"
COLOR 2
PRINT
PRINT "1. Add"
PRINT "2. Subtract"
PRINT "3. Multiply"
PRINT "4. Divide"
PRINT "5. ";
COLOR 20
PRINT "EXIT"
PRINT
COLOR 3
PRINT TAB(30); "Your choice (1-5)? ";
LINE INPUT C$
C = VAL(C$)
COLOR 5
SELECT CASE C
CASE 1
DO UNTIL NoNum > 1 AND NoNum < 100
INPUT "How many numbers do you want to add together"; NoNum
LOOP
FOR I = 1 TO NoNum
PRINT "Number"; I; "= ";
INPUT Num(I)
NEXT I
Add NoNum
CASE 2
INPUT "Number 1 = "; Num(1)
INPUT "Number 2 = "; Num(2)
Subtract
CASE 3
INPUT "Number 1 = "; Num(1)
INPUT "Number 2 = "; Num(2)
Multiply
CASE 4
INPUT "Number 1 = "; Num(1)
INPUT "Number 2 = "; Num(2)
Divide
CASE 5
INPUT "Are you SURE (y/n)"; Sure$
IF LEFT$(UCASE$(Sure$), 1) = "Y" THEN EXIT DO ELSE GOTO LoopStatement
CASE ELSE
PRINT "Bad choice. Try again."
SLEEP 2
GOTO LoopStatement
END SELECT
LoopStatement:
LOOP
END
SUB Add (NoNum)
SUM = 0
FOR I = 1 TO NoNum
SUM = SUM + Num(I)
NEXT I
FOR I = 1 TO NoNum
Num(I) = 0
NEXT I
PRINT "The sum equals"; SUM
SLEEP 5
END SUB
SUB Divide
QUOTIENT = 0
QUOTIENT = Num(1) / Num(2)
QBASE = Num(1) \ Num(2)
REMAINDER = Num(1) MOD Num(2)
PRINT "The quotient is"; QUOTIENT; "or"; QBASE; "with a remainder of"; REMAINDER
SLEEP 5
END SUB
SUB Multiply
PRODUCT = 0
PRODUCT = Num(1) * Num(2)
PRINT "The product is"; PRODUCT
SLEEP 5
END SUB
SUB Subtract
DIFFERENCE = 0
DIFFERENCE = Num(1) - Num(2)
PRINT "The difference is"; DIFFERENCE
SLEEP 5
END SUB